<cfscript>
    view = createObject("component", session.rootDir & ".views.layout");   
    view.init("Status Report","","","Status",index, "Termination");
    view.html(); 
</cfscript>


<cffunction name="index" access="public" output="true" returntype="any">
	<cfscript>
	   import models.*;	
    	Step = ORMExecuteQuery("FROM Steps WHERE StepsID = 20 OR StepsID = 22 OR StepsID = 23 OR StepsID = 24 OR StepsID = 25 OR StepsID = 26 OR StepsID = 27 ORDER BY OrderNo");
    	stepSQL = "FROM StepActions WHERE StepsID = ? AND ActTimeStamp IS NULL";
        getTermRequests = "FROM TerminationRequests WHERE NonSCF = 0 AND TerminationRequestsID = ?";
        getTermRequestsNonSCF = "FROM TerminationRequests WHERE NonSCF = 1 AND TerminationRequestsID = ?";
        getRosetta = "FROM RosettaStone WHERE RosettaID = ?";    	
	</cfscript>
    
	<cfoutput>
    
    <h1 class="title">Status Report</h1>
    <div class="entry">
        Welcome, #Session.EmpInfo.FirstName# #Session.EmpInfo.LastName#.  
        The page details the Steps in the Creation process and lists the 
        number of employees staged at each.  <BR /> <BR />
        
        <cfform name="status" method="post" action="">
        
		<table align="center">
		    <cfloop from="1" to="#ArrayLen(Step)#" index="i">
		    
		        <cfset StepActions = ORMExecuteQuery(stepSQL, [Step[i].getStepsID()] ) />
		        
		        <tr>
		            <td valign="top" colspan="3">
		                <span class="tableHeader">
		                    #Step[i].getStepDesc()# (#ArrayLen(StepActions)#)
		                </span>     
		            </td>
		        </tr>
		        <tr>
		            <td width="25">&nbsp;</td>
		            <td valign="top"> 
		                <table>
		                    <tr>               
		                        <td>
		                            <strong>
                                        <cfif (Session.strAuthType EQ Step[i].getAppGroup() OR Session.strAuthType EQ Session.IT or Session.strAuthType EQ Session.HR) AND Step[i].getPage_Home() NEQ "">
		                                    #( ArrayLen(StepActions) GT 0 ? '<a href="SCF/#Step[i].getPage_Home()#">SCF EMPLOYEES</a>' : 'SCF EMPLOYEES')#
                                        <cfelse>
                                            SCF EMPLOYEES
                                        </cfif>
		                            </strong>     
		                        </td>
                                <td>
                                    <cfif Step[i].getStepsID() EQ 23 AND (Session.strAuthType EQ Step[i].getAppGroup() OR Session.strAuthType EQ Session.IT or Session.strAuthType EQ Session.HR) AND Step[i].getPage_Home() NEQ "">
                                        #( ArrayLen(StepActions) GT 0 ? '<a href="SCF/#Step[i].getPage_Home()#">AD Term</a>' : 'AD Term')#
                                    <cfelse>
                                        &nbsp;
                                    </cfif>                                
                                </td>
                                <td>
                                    <cfif Step[i].getStepsID() EQ 23 AND (Session.strAuthType EQ Step[i].getAppGroup() OR Session.strAuthType EQ Session.IT or Session.strAuthType EQ Session.HR) AND Step[i].getPage_Home() NEQ "">
                                        #( ArrayLen(StepActions) GT 0 ? '<a href="SCF/#Step[i].getPage_Home()#">Kronos Term</a>' : 'Kronos Term')#
                                    <cfelse>
                                        &nbsp;
                                    </cfif> 
                                </td>
		                    </tr>
		                    <cfif ArrayLen(StepActions) GT 0>
		                        <cfloop array="#StepActions#" index="ii">
		                            <cfset TermRequest = ORMExecuteQuery("FROM TerminationRequests WHERE NonSCF <> 1 AND TerminationRequestsID = #ii.getTermReqID()#") />
                                    <cfif ArrayLen(TermRequest) GT 0>
                                        <cfset Employee = CreateObject("component", session.rootDir & ".DatabaseQueries.Kronos").funcGetAllEmployees( val(TermRequest[1].getRosettaID()) )/>
                                        <cfif isDefined("Employee")>
    					                    <tr>                  
    					                        <td>
    					                           <cfif Step[i].getStepsID() EQ 23>					                            
        					                           <a href="SCF/#Step[i].getController()#?TermReqID=#ii.getTermReqID()#">
        					                               #trim(Employee.LastName)#, #trim(Employee.FirstName)#
        					                           </a>
                                                   <cfelse>                                                                                                     
                                                       <a href="SCF/#Step[i].getController()#?TermReqID=#ii.getTermReqID()#">
                                                           #trim(Employee.LastName)#, #trim(Employee.FirstName)#
                                                       </a>
                                                   </cfif>
    					                        </td>
                                                <td>
                                                    <cfif Step[i].getStepsID() EQ 23>                                               
                                                       <a href="SCF/#Step[i].getController()#?TermReqID=#ii.getTermReqID()#">#DateFormat(TermRequest[1].getTermDate(), "mm/dd/yy")#</a>
                                                   <cfelse>&nbsp;</cfif>
                                                </td>
                                                <td>
                                                    <cfif Step[i].getStepsID() EQ 23>                                               
                                                       <a href="SCF/#Step[i].getController()#?TermReqID=#ii.getTermReqID()#">#DateFormat(TermRequest[1].getSysTermDate(), "mm/dd/yy")#</a>
                                                   <cfelse>&nbsp;</cfif>
                                                </td>
    					                    </tr>
                                        </cfif>
                                    </cfif>
		                        </cfloop>
		                    <cfelse>
			                    <tr>           
			                        <td>
			                            <span class="error">At the present time, there are not any employees staged for this step.</span>
			                        </td>
			                    </tr>
		                    </cfif>
		                </table>
		            </td>
		            <td valign="top"> 
		                <table>
		                    <tr>            
		                        <td>
		                            <strong>
                                        <cfif (Session.strAuthType EQ Step[i].getAppGroup() OR Session.strAuthType EQ Session.IT or Session.strAuthType EQ Session.HR) and Step[i].getPage_UserDirect() NEQ ''>
                                            #( ArrayLen(StepActions) ? '<a href="NonSCF/#Step[i].getPage_Home()#">CONTRACTORS</a>' : 'CONTRACTORS')#
                                        <cfelse>
                                            CONTRACTORS
                                        </cfif>                                    
		                            </strong>
		                        </td>
		                    </tr>
		                    <cfif ArrayLen(StepActions) GT 0>
		                        <cfloop array="#StepActions#" index="ii">                                    
                                    <cfset TermRequest = ORMExecuteQuery("FROM TerminationRequests WHERE NonSCF = 1 AND TerminationRequestsID = #ii.getTermReqID()#") />
                                    <cfif ArrayLen(TermRequest) GT 0>
                                        <cfset Rosetta = ORMExecuteQuery("FROM RosettaStone WHERE RosettaID = #TermRequest[1].getRosettaID()#") />                                        
                                        <Cfset EmployeeNonSCF = entityLoadByPK("NonSCFMaster", Rosetta[1].getNonSCFMasterID()) />                                                                  
                                        <cfif isDefined("EmployeeNonSCF")>
                                            <tr>                  
                                                <td>
                                                   <cfif Step[i].getStepsID() EQ 23>                                                
                                                       <a href="NonSCF/#Step[i].getController()#?TermReqID=#ii.getTermReqID()#">
                                                           #EmployeeNonSCF.getLastName() & ", " & EmployeeNonSCF.getFirstName()# 
                                                           (#DateFormat(TermRequest[1].getTermDate(), "mm/dd/yy")#, 
                                                           #DateFormat(TermRequest[1].getSysTermDate(), "mm/dd/yy")#)
                                                       </a>
                                                   <cfelse>
                                                       <a href="NonSCF/#Step[i].getController()#?TermReqID=#ii.getTermReqID()#">
                                                           #EmployeeNonSCF.getLastName() & ", " & EmployeeNonSCF.getFirstName()#
                                                       </a>
                                                   </cfif>                                              
                                                </td>
                                            </tr>
                                        </cfif>
                                    </cfif>
		                        </cfloop>
		                    <cfelse>
			                    <tr>       
			                        <td>
			                            <span class="error">At the present time, there are not any contractors staged for this step.</span>
			                        </td>
			                    </tr>
		                    </cfif>
		                </table>
		            </td>
		        </tr>
		        <tr>           
		            <td>&nbsp;</td>
		        </tr>
		    </cfloop>
		</table>
        </cfform>
    </div>
	</cfoutput>
</cffunction>